package com.brite.android.game.action;

import org.anddev.andengine.entity.sprite.AnimatedSprite;

public class Items {
	public static int INACTIVE_STATUS 	= 1;
	public static int ACTIVE_STATUS		= 2;
	
//	public static int UNKNOWN = 0;
//	public static int AUXILIARY = 1;
//	public static int PROTECTION = 2;
//	public static int SMALL_SCALE_DAMAGE = 3;
//	public static int LARGE_SCALE_DAMAGE = 4;
	
	public static int UNKNOWN = 4;
	public static int AUXILIARY = 0;
	public static int PROTECTION = 1;
	public static int SMALL_SCALE_DAMAGE = 2;
	public static int LARGE_SCALE_DAMAGE = 3;
	
	public AnimatedSprite mInactiveSprite;
	public AnimatedSprite mActiveSprite;
	public TimeCounter mTimeToActiveCounter;
	public TimeCounter mActiveTimeCounter;
	public boolean mIsActive;
	public int typeItem;
	
//	public Region regionActive;
	
//	private void genRegionActive(){
//		if (typeItem == Items.AUXILIARY || typeItem == Items.SMALL_SCALE_DAMAGE || typeItem == Items.PROTECTION) {
//			regionActive = new Region((float)(Math.sqrt(mActiveSprite.getWidthScaled()*mActiveSprite.getWidthScaled() + mActiveSprite.getHeightScaled()*mActiveSprite.getHeightScaled())), new Cordinate(mActiveSprite.getX() + mActiveSprite.getWidthScaled()/2, mActiveSprite.getY() + mActiveSprite.getHeightScaled()/2));
//		}
//	}
	
	public Items(int pTypeItem, AnimatedSprite pInactiveSprite, AnimatedSprite pActiveSprite, 
			float pInactiveTimeTotal, float pActiveTimeTotal) {
		typeItem = pTypeItem;
		mInactiveSprite = pInactiveSprite;
		mActiveSprite = pActiveSprite;
		mTimeToActiveCounter = new TimeCounter(pInactiveTimeTotal);
		mActiveTimeCounter = new TimeCounter(pActiveTimeTotal);
		mIsActive = false;
//		genRegionActive();
	}
	
	public Items(Items item) {
		mInactiveSprite = new AnimatedSprite(item.mInactiveSprite.getX(), item.mInactiveSprite.getY(), item.mInactiveSprite.getTextureRegion());
		if (item.mActiveSprite==null) {
			mActiveSprite = null;
		}else {
			mActiveSprite = new AnimatedSprite(item.mActiveSprite.getX(), item.mActiveSprite.getY(), item.mActiveSprite.getTextureRegion().clone());
		}
		mTimeToActiveCounter = new TimeCounter(item.mTimeToActiveCounter.getTotal());
		mActiveTimeCounter = new TimeCounter(item.mActiveTimeCounter.getTotal());
		mIsActive = false;
		typeItem = item.typeItem;
//		genRegionActive();
	}
	
	public AnimatedSprite getCurrentSprite() {
		return mIsActive ? mActiveSprite : mInactiveSprite; 
	}
}
